﻿package states {
	import levels.*;
	import org.flixel.*;
	import flash.display.*;

	/**
	 * ...
	 * @author test
	 */
	public class MenuState extends FlxState {
		public var _menu:FlxGroup;
		public var btn_size:Array;

		public function MenuState(){
			super();

			init();

			var headLine:FlxText = new FlxText(0, FlxG.height * 0.1, FlxG.width, "Amazing Piggy");
			with (headLine){
				color = 0xff000000;
				size = 50;
				alignment = "center";
			}

			var start_btn:FlxButton = new FlxButton(FlxG.width * 0.5, FlxG.height * 0.75, start_func);

			var btn_sprite:FlxSprite = new FlxSprite(0, 0);
			var button_text:FlxText = new FlxText(0, 0, btn_size.x, "Start");
			button_text.alignment = "center";
			button_text.size = 12;

			btn_sprite.createGraphic(btn_size["x"], btn_size["y"], 0xff000000);

			start_btn.loadGraphic(btn_sprite);
			start_btn.loadText(button_text);

			_menu.add(start_btn);

			this.add(headLine);
			this.add(_menu);
		}

		private function init():void {
			FlxG.mouse.show();

			_menu = new FlxGroup();
			bgColor = 0xffffffff;

			btn_size = new Array();
			btn_size["x"] = 50;
			btn_size["y"] = 25;
		}

		private function start_func():void {
			FlxG.state = new LoadState;
		}
	}

}